package com.pai4j.pgc.config;

import com.pai4j.common.config.annotation.RequireCreatorInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * PGC服务Web MVC配置
 * 注册拦截器等
 *
 * @author: CYM-pai
 * @date: 2025/11/01
 */
@Configuration
public class PgcWebMvcConfigurer implements WebMvcConfigurer {
    
    /**
     * 注册自定义拦截器
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 注册创作者身份校验拦截器
        registry.addInterceptor(requireCreatorInterceptor())
                .addPathPatterns("/pgc-service/**");
    }
    
    /**
     * 创作者身份校验拦截器 Bean
     */
    @Bean
    public RequireCreatorInterceptor requireCreatorInterceptor() {
        return new RequireCreatorInterceptor();
    }
}

